//
//  movieViewController.m
//  UI20_豆瓣电影storyBoard
//
//  Created by 王阳阳 on 16/1/4.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "movieViewController.h"
#import "NetWorkHandler.h"
#import "movieTableViewCell.h"
#import "movie.h"
#import "UIImageView+WebCache.h"
#import "MoviexxxxxxViewController.h"
#import "JIUViewController.h"
@interface movieViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property (nonatomic, strong)NSMutableArray *DataArr;
@property (nonatomic, assign)BOOL isT;
@property (nonatomic, strong)JIUViewController *jiu;
@end

@implementation movieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg.png"] forBarMetrics:UIBarMetricsDefault];
    
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"btn_nav_collection"] style:UIBarButtonItemStylePlain target:self action:@selector(right)];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    [self data];
    
    
    self.isT = NO;
    self.jiu = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]instantiateViewControllerWithIdentifier:@"jiu"];
    
}
- (void)data
{
    NSString *path = @"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/movielist.php";
    
   [NetWorkHandler GETWithURL:path completion:^(id result) {
       NSArray *arr = result[@"result"];
       
       self.DataArr = [movie modelHandlerWithArray:arr];
       [self.tableview reloadData];
   }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _DataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    movieTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    movie *mo = _DataArr[indexPath.row];
    [cell.imagemovie sd_setImageWithURL:[NSURL URLWithString:mo.pic_url]];
    cell.movietitle.text = mo.movieName;
    return cell;
}

- (void)right
{
    _isT = !_isT;
    if (_isT) {
        [UIView transitionFromView:self.view toView:_jiu.view duration:2 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
        }];
    }
    else
    {
        [UIView transitionFromView:_jiu.view toView:self.view duration:2 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
        }];
    }
    
}



- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    MoviexxxxxxViewController *movie = segue.destinationViewController;
    movie.m = _DataArr[_tableview.indexPathForSelectedRow.row];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
